﻿
@{
    ViewBag.Title = "Login";
    Layout = null;
}


<!DOCTYPE html>
<html lang="en">
<head>
    <!--
    ===
    This comment should NOT be removed.

    Charisma v2.0.0

    Copyright 2012-2014 Muhammad Usman
    Licensed under the Apache License v2.0
    http://www.apache.org/licenses/LICENSE-2.0

    http://usman.it
    http://twitter.com/halalit_usman
    ===
    -->
    <meta charset="utf-8">
    <title>Free HTML5 Bootstrap Admin Template</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
    <meta name="author" content="Muhammad Usman">

    <!-- The styles -->
    <link href="/Content/css/bootstrap-cerulean.min.css" rel="stylesheet">
    <link href="/Content/css/charisma-app.css" rel="stylesheet">

    <!-- jQuery -->

    <script src="/scripts/jquery-1.9.1.min.js"></script>
    <script src="/scripts/jquery.unobtrusive-ajax.js"></script>
    <link rel="shortcut icon" href="/Images/favicon.ico">

</head>

<body>
    <div class="ch-container">
        <div class="row">

            <div class="row">
                <div class="col-md-12 center login-header">
                    <h2>欢迎登录德朗诺工作系统</h2>
                </div>
                <!--/span-->
            </div><!--/row-->
            @using (Ajax.BeginForm("LoginSubmit", "Account",
    new AjaxOptions
    {
        OnBegin = "CheckSubmit",
        OnFailure = "onFailure",
        OnSuccess = "onSuccess"
    }))
            {
                <div class="row">
                    <div class="well col-md-5 center login-box">
                        <div class="alert alert-info">
                            请输入你的用户名和密码
                        </div>
                        <div class="input-group input-group-lg">
                            <span class="input-group-addon"><i class="glyphicon glyphicon-user red"></i></span>
                            <input type="text" class="form-control" placeholder="Username" name="UserName" id="UserName">
                        </div>
                        <div class="clearfix"></div><br>

                        <div class="input-group input-group-lg">
                            <span class="input-group-addon"><i class="glyphicon glyphicon-lock red"></i></span>
                            <input type="password" class="form-control" placeholder="Password" name="PassWord" id="PassWord">
                        </div>
                        <div class="clearfix"></div>

                        <div class="input-prepend">
                            <label class="remember" for="remember"><input type="checkbox" id="remember"> Remember me</label>
                        </div>
                        <div class="clearfix"></div>

                        <p class="center col-md-5">
                            <button type="submit" class="btn btn-primary">登录</button>
                        </p>
                    </div>
                    <!--/span-->
                </div>
    <!--/row-->
            }
        </div><!--/fluid-row-->

    </div>

    <input type="hidden" id="returnUrl" value="@(HttpUtility.UrlDecode(Request["returnUrl"]))" />
    <input type="hidden" id="secondCatlog" value="@(CodingLei.Admin.Models.MvcHelper.SecondCatlog())" />
</body>
</html>


<script type="text/javascript">
    function CheckSubmit() {
        if ($.trim($("#UserName").val()).length == 0) {
            alert("请输入用户名！");
            $("#UserName").focus();
            return false;
        }
        if ($.trim($("#PassWord").val()).length == 0) {
            alert("请输入密码！");
            $("#PassWord").focus();
            return false;
        }
    }


    function onFailure(response) {
        alert(response.responseText);
    }

    function onSuccess(data) {
        if (data.IsSuccess) {
            if ($("#returnUrl").val() == null || $("#returnUrl").val() == "") {
                window.location.href = $("#secondCatlog").val() + "/Home/Index";
            } else {
                window.location.href = $("#secondCatlog").val() + $("#returnUrl").val();
            }
        } else {
            alert(data.Message);
        }
    }

</script>
